/* Developed by AJ Kertis and Team PAWS at IST 440w and Pennsylvania State University
 * Code that will decide which code to use based on the hardware used. This could be easily adapted
 * to work with android as well.
 */
// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');
var forms = require('forms');
// create tab group and sets the variable device to the device using the application.
var tabGroup = Titanium.UI.createTabGroup();
var device = Titanium.Platform.model;
Ti.API.info(device);

/*
 * Cat Window for the Cats Tab to display Cats available for adoption.
 */
var cats_win = Titanium.UI.createWindow({
	title:'Cats Available for Adoption',
	backgroundColor:'#FFF',
	url:'paws/cat_name.js',
	 orientationModes : [
	Titanium.UI.PORTRAIT,
	Titanium.UI.UPSIDE_PORTRAIT,
	Titanium.UI.LANDSCAPE_LEFT,
	Titanium.UI.LANDSCAPE_RIGHT
	]
});
/*
 * Dogs Windows for Dogs Tab to display Dogs available for adoption.
 */
var dogs_win = Titanium.UI.createWindow({
	title:'Dogs Available for Adoption',
	backgroundColor:'#FFF',
	url:'paws/dog_name.js',
	 orientationModes : [
	Titanium.UI.PORTRAIT,
	Titanium.UI.UPSIDE_PORTRAIT,
	Titanium.UI.LANDSCAPE_LEFT,
	Titanium.UI.LANDSCAPE_RIGHT
	]
});

/*
 * Creates Cats Tab that will display Cats available for adoption.
 */
var catstab = Titanium.UI.createTab({  
    icon:'paw.png',
    title:'Cats',
    window:cats_win
});
/*
 * Creates Dogs Tab that will display Dogs available for adoption.
 */
var dogstab = Titanium.UI.createTab({
	icon:'bone.png',
	title:'Dogs',
	window:dogs_win
});
/*
var toolbar = Ti.UI.iOS.createToolbar({
	barColor:'#660066',
	bottom:0,
	height:20
});
*/
//win.add(toolbar);
//
// create controls tab and root window
//
/*
 * Window for the Paws Info Tab
 */
var pawsinfowin = Titanium.UI.createWindow({  
    title:'PAWS Information',
    backgroundColor:'#fff',
    orientationModes : [
	Titanium.UI.PORTRAIT,
	Titanium.UI.UPSIDE_PORTRAIT,
	Titanium.UI.LANDSCAPE_LEFT,
	Titanium.UI.LANDSCAPE_RIGHT
	]
});


/*
 * Creates tab for Paws Info and adds the corresponding window.
 */
var pawsinfotab = Titanium.UI.createTab({  
    icon:'search.png',
    title:'PAWS Info',
    window:pawsinfowin
});
/*
 * Creates iOS style table view to display options in the Paws Info tab.
 */
var pawsinfoview = Ti.UI.createTableView({
	style:Titanium.UI.iPhone.TableViewStyle.GROUPED,
	scrollable:false
});
/*
 * Adds rows needed in the TableView for location, contact, and hours of operation.
 * Also adds the labels for each row.
 */
var hours_row = Ti.UI.createTableViewRow({
	hasChild: true
});

var contact_row = Ti.UI.createTableViewRow({
	hasChild: true
	
});
var location_row = Ti.UI.createTableViewRow({
	hasChild: true
});
var location_label = Ti.UI.createLabel({
	left: 9,
	text: "Location of Paws"
});

var about_row = Ti.UI.createTableViewRow({
	hasChild: true
})

var hours_label = Ti.UI.createLabel({
	left: 9,
	text: "Hours of Operation"
});
var contact_label = Ti.UI.createLabel({
	left: 9,
	text: "Contact Paws"
});
var about_label = Ti.UI.createLabel({
	left: 9,
	text: "About Paws"
});
/*
 * Adds the window to the view and the labels to each row.
 * Also, adds the rows to the view.
 */
pawsinfowin.add(pawsinfoview);
hours_row.add(hours_label);
contact_row.add(contact_label);
about_row.add(about_label);
location_row.add(location_label);

pawsinfoview.appendRow(hours_row);
pawsinfoview.appendRow(contact_row);
pawsinfoview.appendRow(about_row);
pawsinfoview.appendRow(location_row);

/*
 * Google Map code to display the location of PAWS in State College.
 * Also, annotates the location with a green pin.
 */
var location_win = Ti.UI.createWindow({title:'Location of Paws'});

var annotations = [
    Ti.Map.createAnnotation({
        latitude: 40.836022,
        longitude: -77.811205,
        title: 'Centre County Paws',
        subtitle: 'State College, PA',
        animate: true,
        pincolor: Ti.Map.ANNOTATION_GREEN
       
    })
];
var mapview = Titanium.Map.createView({
	mapType: Titanium.Map.STANDARD_TYPE,
	region: {latitude:40.835969, longitude:-77.81076,
		     latitudeDelta:0.1, longitudeDelta:0.1},
		     animate:true,
		     regionFit:true,
		     annotations:annotations,
		     userLocation:true
});
location_win.add(mapview);

/*
 * Adds image for the About Paws part of the Paws Info tab.
 * About Paws section of App.
 */

var about_win = Ti.UI.createWindow({title:'About Paws'});
var about_win_table = Ti.UI.createTableViewRow();
var about_image = Ti.UI.createImageView({
	image:"Default-Portrait.png"
});
about_win.add(about_win_table);
about_win.add(about_image);

/*
 * Hours of Operation part of application.
 * Adds correct operating hours and adds the table to the window.
 */
var hours_win = Ti.UI.createWindow({title:'Hours of Operation'});
var hours_win_table = Ti.UI.createTableView({style:Titanium.UI.iPhone.TableViewStyle.GROUPED});
var hours_win_monday = Ti.UI.createTableViewRow({title:'5-7 PM',header:'Monday'});
var hours_win_tue = Ti.UI.createTableViewRow({title:'11-2 PM',header:'Tuesday'});
var hours_win_weekends = Ti.UI.createTableViewRow({title:'11-4 PM',header:'Saturday and Sunday'});
hours_win_table.appendRow(hours_win_monday);
hours_win_table.appendRow(hours_win_tue);
hours_win_table.appendRow(hours_win_weekends);
hours_win.add(hours_win_table);

/*
 * Contact Paws part of Paws Info tab.
 * Adds a row and label for each contact.
 */
var contact_win = Ti.UI.createWindow({title:'Contact Paws'});
var contact_table = Ti.UI.createTableView({style:Titanium.UI.iPhone.TableViewStyle.GROUPED});
var contact_general_row = Ti.UI.createTableViewRow();
var contact_general_label = Ti.UI.createLabel({
	left: 9,
	text: "General"
});
var contact_catadoption_row = Ti.UI.createTableViewRow();
var contact_catadoption_label = Ti.UI.createLabel({
	left: 9,
	text: "Cat Adoptions and Placement"
});
var contact_dogadoption_row = Ti.UI.createTableViewRow();
var contact_dogadoption_label = Ti.UI.createLabel({
	left: 9,
	text: "Dog Adoptions and Placement"
});
var contact_he_cats_row = Ti.UI.createTableViewRow();
var contact_he_cats_label = Ti.UI.createLabel({
	left: 9,
	text: "Happy Endings Cats"
});
var contact_he_dogs_row = Ti.UI.createTableViewRow();
var contact_he_dogs_label = Ti.UI.createLabel({
	left: 9,
	text: "Happy Endings Dogs"
});

var contact_spaying_row = Ti.UI.createTableViewRow();
var contact_spaying_label = Ti.UI.createLabel({
	left: 9,
	text: "Spaying and Neutering"
});
var contact_vol_row = Ti.UI.createTableViewRow();
var contact_vol_label = Ti.UI.createLabel({
	left: 9,
	text: "Volunteering"
});
var contact_dog_vol_row = Ti.UI.createTableViewRow();
var contact_dog_vol_label = Ti.UI.createLabel({
	left: 9,
	text: "Dog Volunteer Training"
});
var contact_mem_row = Ti.UI.createTableViewRow();
var contact_mem_label = Ti.UI.createLabel({
	left: 9,
	text: "Membership"
});
var contact_edu_row = Ti.UI.createTableViewRow();
var contact_edu_label = Ti.UI.createLabel({
	left: 9,
	text: "Education"
});
var contact_dev_row = Ti.UI.createTableViewRow();
var contact_dev_label = Ti.UI.createLabel({
	left: 9,
	text: "Development"
});
var contact_treasurer_row = Ti.UI.createTableViewRow();
var contact_treasurer_label = Ti.UI.createLabel({
	left: 9,
	text: "Treasurer"
});
var contact_president_row = Ti.UI.createTableViewRow();
var contact_president_label = Ti.UI.createLabel({
	
	left: 9,
	text: "President of PAWS"
});
var contact_supervisor_row = Ti.UI.createTableViewRow();
var contact_supervisor_label = Ti.UI.createLabel({
	left: 9,
	text: "Shelter Supervisor"
});
var contact_website_row = Ti.UI.createTableViewRow();
var contact_website_label = Ti.UI.createLabel({
	left: 9,
	text: "Website"
});

contact_table.appendRow(contact_general_row);
contact_table.appendRow(contact_catadoption_row);
contact_table.appendRow(contact_dogadoption_row);
contact_table.appendRow(contact_he_cats_row);
contact_table.appendRow(contact_he_dogs_row);
contact_table.appendRow(contact_vol_row);
contact_table.appendRow(contact_spaying_row);
contact_table.appendRow(contact_dog_vol_row);
contact_table.appendRow(contact_mem_row);
contact_table.appendRow(contact_edu_row);
contact_table.appendRow(contact_dev_row);
contact_table.appendRow(contact_treasurer_row);
contact_table.appendRow(contact_president_row);
contact_table.appendRow(contact_supervisor_row);
contact_table.appendRow(contact_website_row);
contact_general_row.add(contact_general_label);
contact_catadoption_row.add(contact_catadoption_label);
contact_dogadoption_row.add(contact_dogadoption_label);
contact_he_cats_row.add(contact_he_cats_label);
contact_he_dogs_row.add(contact_he_dogs_label);
contact_vol_row.add(contact_vol_label);
contact_spaying_row.add(contact_spaying_label);
contact_dog_vol_row.add(contact_dog_vol_label);
contact_mem_row.add(contact_mem_label);
contact_edu_row.add(contact_edu_label);
contact_dev_row.add(contact_dev_label);
contact_treasurer_row.add(contact_treasurer_label);
contact_president_row.add(contact_president_label);
contact_supervisor_row.add(contact_supervisor_label);
contact_website_row.add(contact_website_label);
contact_win.add(contact_table);


/*
 * Creates the emailDialog for each contact and will use the built in
 * mail application to send email to PAWS.
 */

var general_emailDialog = Titanium.UI.createEmailDialog();
general_emailDialog.subject = "General Question for PAWS"; 
general_emailDialog.toRecipients = ['mail@centrecountypaws.org']; 

var catadoption_emailDialog = Titanium.UI.createEmailDialog();
catadoption_emailDialog.subject = "Question for PAWS about Cat Adoptions"; 
catadoption_emailDialog.toRecipients = ['cats@centrecountypaws.org'];

var dogadoption_emailDialog = Titanium.UI.createEmailDialog();
dogadoption_emailDialog.subject = "Question for PAWS about Dog Adoptions"; 
dogadoption_emailDialog.toRecipients = ['dogs@centrecountypaws.org'];

var happyendings_cat_emailDialog = Titanium.UI.createEmailDialog();
happyendings_cat_emailDialog.subject = "Question for PAWS about Happy Endings for Cats";
happyendings_cat_emailDialog.toRecipients = ['cats@centrecountypaws.org'];

var happyendings_dog_emailDialog = Titanium.UI.createEmailDialog();
happyendings_dog_emailDialog.subject = "Question for PAWS about Happy Endings for Dogs";
happyendings_dog_emailDialog.toRecipients = ['dogs@centrecountypaws.org'];

var volunteer_emailDialog = Titanium.UI.createEmailDialog();
volunteer_emailDialog.subject = "Question for PAWS about Volunteering";
volunteer_emailDialog.toRecipients = ['newvolunteer@centrecountypaws.org'];

var spaying_neuter_emailDialog = Titanium.UI.createEmailDialog();
spaying_neuter_emailDialog.subject = "Question for PAWS about Spaying and Neutering";
spaying_neuter_emailDialog.toRecipients = ['spayneuter@centrecountypaws.org'];

var dog_vol_training_emailDialog = Titanium.UI.createEmailDialog();
dog_vol_training_emailDialog.subject = "Question for PAWS about Dog Volunteer Training";
dog_vol_training_emailDialog.toRecipients = ['dogvolunteertraining@centrecountypaws.org'];

var membership_emailDialog = Titanium.UI.createEmailDialog();
membership_emailDialog.subject = "Question for PAWS about Membership";
membership_emailDialog.toRecipients = ['membership@centrecountypaws.org'];

var lost_found_emailDialog = Titanium.UI.createEmailDialog();
lost_found_emailDialog.subject = "Question for PAWS about Lost and Found";
lost_found_emailDialog.toRecipients = ['lost_found@centrecountypaws.org'];

var edu_emailDialog = Titanium.UI.createEmailDialog();
edu_emailDialog.subject = "Question for PAWS about Education";
edu_emailDialog.toRecipients = ['education@centrecountypaws.org'];

var dev_emailDialog = Titanium.UI.createEmailDialog();
dev_emailDialog.subject = "Question for PAWS about Development";
dev_emailDialog.toRecipients = ['mail@centrecountypaws.org'];

var treasurer_emailDialog = Titanium.UI.createEmailDialog();
treasurer_emailDialog.subject = "Question for Treasurer of PAWS";
treasurer_emailDialog.toRecipients = ['treasurer@centrecountypaws.org'];

var president_emailDialog = Titanium.UI.createEmailDialog();
president_emailDialog.subject = "Question for President of PAWS";
president_emailDialog.toRecipients = ['president@centrecountypaws.org'];

var shelter_super_emailDialog = Titanium.UI.createEmailDialog();
shelter_super_emailDialog.subject = "Question for Shelter Supervisor";
shelter_super_emailDialog.toRecipients = ['lisa_bahr@centrecountypaws.org'];

var website_emailDialog = Titanium.UI.createEmailDialog();
website_emailDialog.subject = "Question about PAWS Website";
website_emailDialog.toRecipients = ['webmaster@centrecountypaws.org']; 

/*
 * Involved Window that was taken out of the application near the end.
 * We did not know enough information to post to a web server.
 */
/*
var involved_win = Titanium.UI.createWindow({  
    title:'Get Involved',
    backgroundColor:'#fff'
});

involved_win.orientationModes = [
	Titanium.UI.PORTRAIT,
	Titanium.UI.UPSIDE_PORTRAIT,
	Titanium.UI.LANDSCAPE_LEFT,
	Titanium.UI.LANDSCAPE_RIGHT
];

var involved = Titanium.UI.createTab({  
    icon:'KS_nav_ui.png',
    title:'Get Involved',
    window:involved_win
});

var tbl_data = [
	{title:'Volunteer Application Form', hasChild:true},
	{title:'Foster Application Form', hasChild:true},
	{title:'Membership Form'}
];
*/
/*var table = Titanium.UI.createTableView({
	data:tbl_data
});
*/
/*
var mainmenu = Ti.UI.createTableView({
	style:Titanium.UI.iPhone.TableViewStyle.GROUPED,
	scrollable:false
});

var volunteer_row = Ti.UI.createTableViewRow({
	hasChild: true
});

var volunteer_label = Ti.UI.createLabel({
	left: 9,
	text: "Volunteer Application Form"
});
volunteer_row.add(volunteer_label);
mainmenu.appendRow(volunteer_row);

var appform_row = Ti.UI.createTableViewRow({
	hasChild: true
});

var appform_label = Ti.UI.createLabel({
	left: 9,
	text: "Foster Application Form"
});
appform_row.add(appform_label);
mainmenu.appendRow(appform_row);

memberform_row = Ti.UI.createTableViewRow({
	hasChild: true
});

memberform_label = Ti.UI.createLabel({
	left: 9,
	text: "Membership Form"
});
memberform_row.add(memberform_label);
mainmenu.appendRow(memberform_row);

involved_win.add(mainmenu);

*/
/*
 * Creates window for Web View of PAWS website. 
 * Also creates the Paws Website tab. The back button will only be activated if
 * someone goes forward from the main PAWS web page.
 */
var web_win = Titanium.UI.createWindow({
	
	
});

web_win.orientationModes = [
	Titanium.UI.PORTRAIT,
	Titanium.UI.UPSIDE_PORTRAIT,
	Titanium.UI.LANDSCAPE_LEFT,
	Titanium.UI.LANDSCAPE_RIGHT
];

var webtab = Titanium.UI.createTab({  
    icon:'world.png',
    title:'Paws Website',
    window:web_win
});
var backBtn = Titanium.UI.createButton({
	title:"Back",
	bottom:0,
	right:12,
	width:48,
	height:36
	
});

var webview = Titanium.UI.createWebView({url:'http://centrecountypaws.org'});

web_win.add(webview);
web_win.add(backBtn);
backBtn.hide();
/*
 * EventListener to check if the web site can go back and if it can't the
 * back button will be hidden.
 */
webview.addEventListener("load",function(e) {
	if (webview.canGoBack()){
		backBtn.show();
	}else{
		backBtn.hide();
	}

});
/*
 * eventlistener to send the webview back if the button is clicked.
 */
backBtn.addEventListener('click', function(e) {
	webview.goBack();
});
/*
var sub_win1 = Ti.UI.createWindow({title:'Volunteer'});
var sub_table1 = Ti.UI.createTableView({style:Titanium.UI.iPhone.TableViewStyle.GROUPED});
var sub_row1 = Ti.UI.createTableViewRow();
var sub_label1 = Ti.UI.createLabel({left:9, text: "Volunteer with PAWS!"});
sub_row1.add(sub_label1);
sub_table1.appendRow(sub_row1);
sub_win1.add(sub_table1);
*/
// sub window 2
//var sub_win2 = Ti.UI.createWindow({title:'Application Form'});
/*var firstname = Titanium.UI.createTextField({
	color:'#336699',
	top:100,
	left:10,
	width:300,
	height:40,
	hintText:'First Name',
	paddingLeft:8,
	paddingRight:8,
	keyboardType:Titanium.UI.KEYBOARD_DEFAULT,
	returnKeyType:Titanium.UI.RETURNKEY_NEXT,
	suppressReturn:false
});*/
/*
 * sets the background color for all the windows including pictures and all the tabs.
 */
Ti.UI.backgroundColor = '#ddd';
//var forms = require('forms);
/*
 * fields array that was used for creating form that was disabled in application.
 */
/*
var fields = [
	{ title:'First Name', type:'text', id:'firstname'},
	{ title:'Last Name', type:'email', id:'lastname'},
	{ title:'Nickname', type:'email', id:'nickname'},
	{ title:'Street 1', type:'text', id:'address1'},
	{ title:'Street 2', type:'text', id:'address2'},
	{ title:'City', type:'text', id:'city'},
	{ title:'State', type:'picker', id:'state', data: [
			'Alabama', 'Alaska', 'Arizona', 'Arkansas',
			'California', 'Colorado', 'Connecticut', 'Delaware',
			'Florida', 'Georgia', 'Hawaii', 'Idaho',
			'Illinois', 'Indiana', 'Iowa', 'Kansas',
			'Kentucky', 'Louisiana', 'Maine', 'Maryland',
			'Massachusetts', 'Michigan', 'Minnesota', 'Mississippi',
			'Missouri', 'Montana', 'Nebraska', 'Nevada',
			'New Hampshire', 'New Jersey', 'New Mexico', 'New York',
			'North Carolina', 'North Dakota', 'Ohio', 'Oklahoma',
			'Oregon', 'Pennyslvania', 'Rhode Island', 'South Carolina',
			'South Dakota', 'Tennessee', 'Texas','Utah',
			'Vermont','Virginia','Washington','West Virginia'
	]},
	{ title: 'Zip Code', type:'number',id:'zip'},
	{ title: 'Home Phone', type:'phone', id:'homephone'},
	{ title: 'Work Phone', type:'phone', id:'workphone'},
	{ title: 'Cell Phone', type:'phone', id:'cellphone'},
	{ title: 'Email Address',type:'email', id:'email'},
	{ title: 'Date of birth', type:'date', id:'dob'},
	{ title: 'Gender', type:'picker', id:'gender', data: [
			 'Male','Female'
	]}
	
	
	
	
];

var form = forms.createForm({
	style: forms.STYLE_LABEL,
	fields: fields
});
*/

//sub_win2.add(form);

// sub window 3
/*
var sub_win3 = Ti.UI.createWindow({title:'Membership Form'});
var sub_table3 = Ti.UI.createTableView({style:Titanium.UI.iPhone.TableViewStyle.GROUPED});
var sub_row3 = Ti.UI.createTableViewRow();
var sub_label3 = Ti.UI.createLabel({left:9, text: "Apply for Membership"});
sub_row3.add(sub_label3);
sub_table3.appendRow(sub_row3);
sub_win3.add(sub_table3);
*/
/*
var cat_win = Ti.UI.createWindow({
	title:'Cats for Adoption',
	url:'paws/cat_name.js'
});
var dogswin = Ti.UI.createWindow({
	    title:'Dogs for Adoption',
		url:'paws/dog_name.js'
});

*/

/*
 * code that was used for testing xml retrieval.
 */
/*
var dog_win = Ti.UI.createWindow({title:'Adopt Dogs'});
var xhr = Titanium.Network.createHTTPClient();
Ti.API.info(device);
*/

/*
xhr.onload = function()
{
	Ti.API.info('twitter xml ' + this.responseXML + ' text ' + this.responseText);
	var doc = this.responseXML.documentElement;
	var elements = doc.getElementsByTagName("title");
	var DogName = elements.item(0);
	Ti.API.info("Album Title = " + DogName.text);

	var dogname = Ti.UI.createLabel({
		textAlign:'center',
		height:'auto',
		width:'auto',
		top:20,
		text:DogName.text
	});
	Ti.UI.currentWindow.add(dogname);

	var textarea = Ti.UI.createTextArea({borderRadius:5,borderWidth:2,borderColor:'#999',backgroundColor:'#111',color:'yellow',bottom:10,left:10,right:10,height:300,font:{fontFamily:'courier',fontSize:10}});
	textarea.value = this.responseText;
	Ti.UI.currentWindow.add(textarea);
};
// open the client
xhr.open('GET','http://vimeo.com/api/v2/lockdownprojects/albums.xml');

// send the data
xhr.send();

/*
var data = [];
var dog_table = Ti.UI.createTableView({style:Titanium.UI.iPhone.TableViewStyle.GROUPED});
//var dog_row = Ti.UI.createTableViewRow();



//var url = "http://vimeo.com/api/v2/lockdownprojects/albums.xml";
var url = "http://www.centrecountypaws.org/xml/dogs.cfm";
var xhr = Titanium.Network.createHTTPClient();
// open the client
xhr.onload = function() {
	
	var doc = this.responseXML.documentElement;
	//Ti.API.info('twitter xml ' + this.responseXML + ' text ' + this.responseText);
	var items = doc.documentElement.getElementsByTagName("dog");
	

	//var elements = doc.getElementsByTagName("album");
	for (var i=0;i<items.length;i++){
			data.push({
				title: items.item(i).getElementsByTagName("name").item(0).text
			});
	}
	table.data = data;
};
xhr.onerror = function(e) {
// should do something more robust
alert('Network error '+e.error);
};

	
	//Ti.API.info("DogName = " + DogName.text);
	
	
	//Ti.UI.currentWindow.add(dog_name);
	
	//var textarea = Ti.UI.createTextArea({borderRadius:5,borderWidth:2,borderColor:'#999',backgroundColor:'#111',color:'yellow',bottom:10,left:10,right:10,height:300,font:{fontFamily:'courier',fontSize:10}});
	//textarea.value = this.responseText;
	//Ti.UI.currentWindow.add(textarea);
	//dog_row.add(dog_row);
	
	

xhr.open('GET',url);
xhr.send();
dog_win.add(dog_table);



// send the data

//var dog_label = Ti.UI.createLabel({left:9, text: "Dog for adoption"});


var adopted_cats_win = Ti.UI.createWindow({title:'Adopted Cats'});
var adopted_cats_table = Ti.UI.createTableView({style:Titanium.UI.iPhone.TableViewStyle.GROUPED});
var adopted_cats_row = Ti.UI.createTableViewRow();
var adopted_cats_label = Ti.UI.createLabel({left:9, text: "Cats Adopted"});
adopted_cats_row.add(adopted_cats_label);
adopted_cats_table.appendRow(adopted_cats_row);
adopted_cats_win.add(adopted_cats_table);
*/
/*
var adopted_dogs_win = Ti.UI.createWindow({title:'Adopted Dogs'});
var adopted_dogs_table = Ti.UI.createTableView({style:Titanium.UI.iPhone.TableViewStyle.GROUPED});
var adopted_dogs_row = Ti.UI.createTableViewRow();
var adopted_dogs_label = Ti.UI.createLabel({left:9, text: "Dogs Adopted"});
adopted_dogs_row.add(adopted_dogs_label);
adopted_dogs_table.appendRow(adopted_dogs_row);
adopted_dogs_win.add(adopted_dogs_table);
*/



/*
volunteer_row.addEventListener('click', function (e){
	involved.open(sub_win1);
});

appform_row.addEventListener('click', function (e){
	involved.open(sub_win2);
});

memberform_row.addEventListener('click', function(e){
	involved.open(sub_win3);
});
*/
/*
 * EventListeners for Hours of Operation Row and About Paws Row.
 * Paws Info tab.
 */
hours_row.addEventListener('click', function(e){
	pawsinfotab.open(hours_win);
});
about_row.addEventListener('click', function(e){
	pawsinfotab.open(about_win);
});

contact_row.addEventListener('click', function(e){
	pawsinfotab.open(contact_win);
})
location_row.addEventListener('click', function(e){
	pawsinfotab.open(location_win);
});

/*
 * Event Listeners for contacting Paws on the Paws Info tab.
 */
contact_general_row.addEventListener('click', function(e){
	pawsinfotab.open(general_emailDialog.open());
});
contact_catadoption_row.addEventListener('click', function(e){
	pawsinfotab.open(catadoption_emailDialog.open());
});
contact_dogadoption_row.addEventListener('click', function(e){
	pawsinfotab.open(dogadoption_emailDialog.open());
});
contact_he_cats_row.addEventListener('click', function(e){
	pawsinfotab.open(happyendings_cat_emailDialog.open());
});
contact_he_dogs_row.addEventListener('click', function(e){
	pawsinfotab.open(happyendings_dog_emailDialog.open());
});
contact_vol_row.addEventListener('click', function(e){
	pawsinfotab.open(volunteer_emailDialog.open());
});
contact_spaying_row.addEventListener('click', function(e){
	pawsinfotab.open(spaying_neuter_emailDialog.open());
});
contact_dog_vol_row.addEventListener('click', function(e){
	pawsinfotab.open(dog_vol_training_emailDialog.open());
});
contact_mem_row.addEventListener('click', function(e){
	pawsinfotab.open(membership_emailDialog.open());
});
contact_edu_row.addEventListener('click', function(e){
	pawsinfotab.open(edu_emailDialog.open());
});

contact_dev_row.addEventListener('click', function(e){
	pawsinfotab.open(dev_emailDialog.open());
});

contact_treasurer_row.addEventListener('click', function(e){
	pawsinfotab.open(treasurer_emailDialog.open());
});

contact_president_row.addEventListener('click', function(e){
	pawsinfotab.open(president_emailDialog.open());
});

contact_supervisor_row.addEventListener('click', function(e){
	pawsinfotab.open(shelter_super_emailDialog.open());
});
contact_website_row.addEventListener('click', function(e){
	pawsinfotab.open(website_emailDialog.open());
});

//
//  add tabs
//
tabGroup.addTab(catstab);
tabGroup.addTab(dogstab);  
tabGroup.addTab(pawsinfotab);
tabGroup.addTab(webtab);
//tabGroup.addTab(involved);
  


// open tab group
tabGroup.open();
